import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

public class VendingMachineItemTest {
	VendingMachineItem item1, item2, item3;
	
	/**
	 * Create two valid items for testing. Item1 is 
	 * used for validating boundary conditions
	 */
	@Before
	public void setUp() throws Exception {
		item1 = new VendingMachineItem(null, 0);
		item2 = new VendingMachineItem("Soda", 1.50);
	}
	
	/**
	 * Create one invalid item, expecting an exception
	 * to be thrown because price < 0
	 */
	@Test(expected=VendingMachineException.class) 
	public void setUpFail() {
		item3 = new VendingMachineItem("Pizza", -1.00);
	}
	
	/**
	 * Test the getName() method. Expecting strings
	 */
	@Test
	public void testGetName() {
		assertNull("Null Check:", item1.getName());
		assertEquals("Soda", item2.getName());
	}

	/**
	 * Test the getPrice method. Expecting double values
	 * within 0.0001
	 */
	@Test
	public void testGetPrice() {
		assertEquals(0, item1.getPrice(), 0.0001);
		assertEquals(1.50, item2.getPrice(), 0.0001);
	}
}
